<extend name="Public/base"/>
<block name="style">
    <link rel="stylesheet" href="__STATIC__/styles/index.css">
</block>
<block name="content">
    <section class="content">
        <div class="box">
            <form id="webForm" action="{:U('updateConfig')}" method="post">
                <div class="box-header with-border">
                    <h3 class="box-title">web后台配置</h3>
                </div>
                <div class="box-body">
                    <div class="form-group row">
                        <label class="col-sm-2 control-label">地图自动更新时间:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="map_refresh_interval" name="map_refresh_interval" value="{$map_refresh_interval|default=''}" >
                        </div>
                        <label class="col-sm-2 control-label">秒</label>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-6">
                        <button type="submit" class="btn btn-primary submit-btn">保存</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">app配置</h3>
            </div>
            <div class="box-body">
                <form id="appForm" action="{:U('updateConfig')}" method="post">


                    <div class="form-group row">
                        <label class="col-sm-2 control-label">用户坐标上报间隔:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="app_report_interval" name="app_report_interval" value="{$app_report_interval|default=''}" >
                        </div>
                        <label class="col-sm-2 control-label">秒</label>
                    </div>


                    <div class="form-group row">
                        <label class="col-sm-2 control-label">地图默认城市:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="default_city" name="default_city" value="{$default_city|default=''}" >
                        </div>
                    </div>


                    <div class="form-group row">
                        <label class="col-sm-2 control-label">信息发送文件最大上传:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="max_send_file" name="max_send_file" value="{$max_send_file|default=''}" >
                        </div>
                        <label class="col-sm-2 control-label">MB</label>
                    </div>

                    <div class="form-group row">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-6">
                            <button type="submit" class="btn btn-primary submit-btn">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </section>
</block>


<block name="script">
    <script>
        function initValidate(){
            $('#webForm').validate({
                debug:true,
                submitHandler:function (form) {
                    var url = $(form).prop('action');
                    var postData = $(form).serialize();
                    $.post(url,postData, function(data){
                        if(data.status == 1){
                            layer.msg('修改成功');
                        }else{
                            layer.msg('修改失败');
                        }
                    });
                },
                rules:{
                    map_refresh_interval:{
                        required:true,
                        digits:true
                    }
                },
                messages:{
                    map_refresh_interval:{
                        required:"这是必填字段",
                        digits:"只能输入数字"
                    }
                }
            });


            $('#appForm').validate({
                debug:true,
                submitHandler:function (form) {
                    var url = $(form).prop('action');
                    var postData = $(form).serialize();
                    $.post(url,postData, function(data){
                        if(data.status == 1){
                            layer.msg('修改成功');
                        }else{
                            layer.msg('修改失败');
                        }
                    });
                },
                rules:{
                    app_report_interval:{
                        required:true,
                        digits:true
                    },
                    default_city:"required",
                    max_send_file:{
                        required:true,
                        digits:true
                    }
                },
                messages:{
                    app_report_interval:{
                        required:"这是必填字段",
                        digits:"只能输入数字"
                    },
                    default_city:'请填写默认城市',
                    max_send_file:{
                        required:"这是必填字段",
                        digits:"只能输入数字"
                    }
                }
            });

        }

        $(function () {
            initValidate();
        })
    </script>
</block>